package com.yufubao.api.controller.popularize.authorization;


import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.result.ResponseResult;
import com.yufubao.model.dto.popularize.authorization.BeesInfoDto;
import com.yufubao.model.pojo.popularize.authorization.BeesInfoEntity;
import com.yufubao.service.service.popularize.authorization.BeesInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


/**
 * 推广人/小蜜蜂人员表
 *
 * @author zhangzhan
 * @email 52194440@qq.com
 * @date 2024-09-15 23:45:03
 */
@Api("推广人/小蜜蜂人员表")
@RestController
@RequestMapping("/applet/popularize/beesinfo")
public class BeesInfoController {

    @Autowired
    private BeesInfoService beesInfoService;

    /**
     * 新增小蜜蜂
     */
    @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
    @ApiOperation(value = "推广人/小蜜蜂人员表保存")
    @SystemLog(info = "推广人/小蜜蜂人员表保存")
    public ResponseResult saveInfo(@RequestBody BeesInfoDto dto) {
        beesInfoService.saveInfo(dto);

        return ResponseResult.ok();
    }


    //================================================================================

    /**
     * 信息
     */
    @RequestMapping(value = "/info/{beesId}", method = RequestMethod.GET)
    @ApiOperation(value = "推广人/小蜜蜂人员表信息")
    @SystemLog(info = "推广人/小蜜蜂人员表信息")
    public ResponseResult info(@PathVariable("beesId") Long beesId) {
        BeesInfoEntity beesInfo = beesInfoService.getById(beesId);

        return ResponseResult.okResultPage("BeesInfo", beesInfo);
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation(value = "推广人/小蜜蜂人员表修改")
    @SystemLog(info = "推广人/小蜜蜂人员表修改")
    public ResponseResult update(@RequestBody BeesInfoEntity beesInfo) {
        beesInfoService.updateById(beesInfo);

        return ResponseResult.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation(value = "推广人/小蜜蜂人员表删除")
    @SystemLog(info = "推广人/小蜜蜂人员表删除")
    public ResponseResult delete(@RequestBody Long[] beesIds) {
        beesInfoService.removeByIds(Arrays.asList(beesIds));

        return ResponseResult.ok();
    }

}
